package com.auemall.controller;

import org.apache.shiro.SecurityUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


@Controller
public class LoginController {

	/**
	 * 登录页面
	 */
	@RequestMapping("/")
	public String showIndex() {
		return "login";
	}
	
	@RequestMapping("/index")
	public String showMain() {
		
		return "index";
	}
	
	
	/**
	 * 展示其他页面
	 * <p>Title: showpage</p>
	 * <p>Description: </p>
	 * @param page
	 * @return
	 */ 
	@RequestMapping("/{page}")
	public String showpage(@PathVariable String page) {
		return page;
	}
	
	 /**
     * 未授权
     * @return {String}
     */
	@RequestMapping("/unauth")
	
    public String unauth() {
    
		if (SecurityUtils.getSubject().isAuthenticated() == false) {
            return "redirect:/login";
        }
        
		return "unauth";
    }
	
	
	 /**
     * 退出
     * @return {Result}
     */
	@RequestMapping("/logout")
	
    @ResponseBody
    public Object logout() {
       
		return "login";
    }
}
